#!/bin/bash

echo "=========================================="
echo "   安装Demo Survey系统服务"
echo "=========================================="
echo

# 复制服务文件到systemd目录
echo "1. 复制服务文件到systemd目录..."
sudo cp demosurvey-backend.service /etc/systemd/system/
sudo cp demosurvey-frontend.service /etc/systemd/system/

# 重新加载systemd配置
echo "2. 重新加载systemd配置..."
sudo systemctl daemon-reload

# 启用服务（开机自启动）
echo "3. 启用服务（开机自启动）..."
sudo systemctl enable demosurvey-backend.service
sudo systemctl enable demosurvey-frontend.service

echo
echo "=========================================="
echo "服务安装完成！"
echo
echo "服务管理命令:"
echo "启动服务: sudo systemctl start demosurvey-backend demosurvey-frontend"
echo "停止服务: sudo systemctl stop demosurvey-backend demosurvey-frontend"
echo "重启服务: sudo systemctl restart demosurvey-backend demosurvey-frontend"
echo "查看状态: sudo systemctl status demosurvey-backend demosurvey-frontend"
echo "查看日志: sudo journalctl -u demosurvey-backend -f"
echo "         sudo journalctl -u demosurvey-frontend -f"
echo "=========================================="